package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class Return implements IOPer{
    @Override
    public void work(BookList bookList) {
        System.out.println("输入你要归还的书名");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        int sz =bookList.getUsersize();
        for (int i = 0; i < sz; i++) {
            Book book = bookList.getBook(i);
            if (book.getName().equals(name)&&book.isOut()==true){
                book.setOut(false);
                bookList.setBooks(i,book);
                System.out.println("成功归还");
                System.out.println(book);
                return;
            }
            if (book.isOut()==false) {
                System.out.println("未被借出");
                System.out.println(book);
                return;
            }
        }
        System.out.println("未找到该书");
    }
}
